***************************************************
* Calculation of Bresnahan-Reiss Entry Thresholds *
***************************************************

qui{
	
	margins if cat_ucc==1, expression((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1])) atmeans
	matrix t_monopoly = r(b)*`1'
	matrix se_monopoly = r(V)
	matrix se_monopoly = sqrt(se_monopoly[1,1])*`1'

	margins if cat_ucc==2, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2) atmeans
	matrix t_duopoly = r(b)*`1'
	matrix se_duopoly = r(V)
	matrix se_duopoly = sqrt(se_duopoly[1,1])*`1'

	margins if cat_ucc==3, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3) atmeans
	matrix t_nfirms3 = r(b)*`1'
	matrix se_f3 = r(V)
	matrix se_f3 = sqrt(se_f3[1,1])*`1'

	margins, expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2)/((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1]))) atmeans
	matrix t_2f_1f = t_duopoly[1,1]/t_monopoly[1,1]
	matrix se_t21 = r(V)
	matrix se_t21 = sqrt(se_t21[1,1])
	
	margins, expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3)/(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:n_hospaffucc_geo]*n_hospaffucc_geo + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2)) atmeans
	matrix t_3f_2f = t_nfirms3[1,1]/t_duopoly[1,1]
	matrix se_t32 = r(V)
	matrix se_t32 = sqrt(se_t32[1,1])

	putexcel `4'2 = t_monopoly[1,1]
	putexcel `4'3 = se_monopoly[1,1]
	putexcel `4'4 = t_duopoly[1,1]
	putexcel `4'5 = se_duopoly[1,1]
	putexcel `4'6 = t_nfirms3[1,1]
	putexcel `4'7 = se_f3[1,1]
	putexcel `4'11 = t_2f_1f[1,1]
	putexcel `4'12 = se_t21[1,1]
	putexcel `4'13 = t_3f_2f[1,1]
	putexcel `4'14 = se_t32[1,1]

	margins if cat_hosp2==1, expression((_b[hosp_f:con_intensity]*con_intensity + _b[hosp_f:cms_wage_index]*cms_wage_index + _b[/hosp_g1])/(_b[hosp_v:rural]*rural + _b[hosp_v:income_pc]*income_pc + _b[hosp_v:hispanic]*hispanic + _b[hosp_v:nonhisp_black]*nonhisp_black + _b[hosp_v:gte_highschool]*gte_highschool  + _b[hosp_v:age_65]*age_65 + _b[hosp_v:uninsured]*uninsured + _b[/hosp_a1])/2) atmeans
	matrix t_monopoly_h = r(b)*`2'
	matrix se_monopoly_h = r(V)
	matrix se_monopoly_h = sqrt(se_monopoly_h[1,1])*`2'
		
	putexcel `4'18 = t_monopoly_h[1,1]
	putexcel `4'19 = se_monopoly_h[1,1]

	margins if cat_aucc==1, expression((_b[aucc_f:cms_wage_index]*cms_wage_index + _b[/aucc_g1])/(_b[aucc_v:n_hospitals]*n_hospitals + _b[aucc_v:n_urgentcare]*n_urgentcare + _b[aucc_v:rural]*rural + _b[aucc_v:income_pc]*income_pc + _b[aucc_v:hispanic]*hispanic + _b[aucc_v:nonhisp_black]*nonhisp_black + _b[aucc_v:gte_highschool]*gte_highschool  + _b[aucc_v:age_65]*age_65 + _b[aucc_v:uninsured]*uninsured + _b[/aucc_a1])) atmeans
	matrix t_monopoly = r(b)*`3'
	matrix se_monopoly = r(V)
	matrix se_monopoly = sqrt(se_monopoly[1,1])*`3'

	putexcel `4'21 = t_monopoly[1,1]
	putexcel `4'22 = se_monopoly[1,1]
	
	margins if cat_aucc==2, expression((_b[aucc_f:cms_wage_index]*cms_wage_index + _b[/aucc_g1] +_b[/aucc_g2])/(_b[aucc_v:n_hospitals]*n_hospitals + _b[aucc_v:n_urgentcare]*n_urgentcare + _b[aucc_v:rural]*rural + _b[aucc_v:income_pc]*income_pc + _b[aucc_v:hispanic]*hispanic + _b[aucc_v:nonhisp_black]*nonhisp_black + _b[aucc_v:gte_highschool]*gte_highschool + _b[aucc_v:uninsured]*uninsured + _b[aucc_v:age_65]*age_65 + _b[/aucc_a1] - _b[/aucc_a2])) atmeans
	matrix t_duopoly = r(b)*`3'
	matrix se_duopoly = r(V)
	matrix se_duopoly = sqrt(se_duopoly[1,1])*`3'
	
	putexcel `4'23 = t_duopoly[1,1]
	putexcel `4'24 = se_duopoly[1,1]
	
	margins, expression(((_b[aucc_f:cms_wage_index]*cms_wage_index + _b[/aucc_g1] +_b[/aucc_g2])/(_b[aucc_v:n_hospitals]*n_hospitals + _b[aucc_v:n_urgentcare]*n_urgentcare + _b[aucc_v:rural]*rural + _b[aucc_v:income_pc]*income_pc + _b[aucc_v:hispanic]*hispanic + _b[aucc_v:nonhisp_black]*nonhisp_black + _b[aucc_v:gte_highschool]*gte_highschool + _b[aucc_v:uninsured]*uninsured + _b[aucc_v:age_65]*age_65 + _b[/aucc_a1] - _b[/aucc_a2]))/((_b[aucc_f:cms_wage_index]*cms_wage_index + _b[/aucc_g1])/(_b[aucc_v:n_hospitals]*n_hospitals + _b[aucc_v:n_urgentcare]*n_urgentcare + _b[aucc_v:rural]*rural + _b[aucc_v:income_pc]*income_pc + _b[aucc_v:hispanic]*hispanic + _b[aucc_v:nonhisp_black]*nonhisp_black + _b[aucc_v:gte_highschool]*gte_highschool + _b[aucc_v:uninsured]*uninsured + _b[aucc_v:age_65]*age_65 + _b[/aucc_a1]))) atmeans
	matrix t_2f_1f = t_duopoly[1,1]/t_monopoly[1,1]
	matrix se_t21 = r(V)
	matrix se_t21 = sqrt(se_t21[1,1])
	
	putexcel `4'27 = t_2f_1f[1,1]
	putexcel `4'28 = se_t21[1,1]	
}
